package nju.software.xkxt.service.convertor;

import org.springframework.beans.BeanUtils;

import nju.software.xkxt.biz.vo.UserVO;
import nju.software.xkxt.data.dataobject.UserDO;
import nju.software.xkxt.service.model.UserModel;

/**
 * @author typ
 * 
 */
public class UserConvertor {
	/**
	 * model to do
	 * 
	 * @param userModel
	 * @return
	 */
	public static UserDO modelToDo(UserModel userModel) {
		UserDO userDO = new UserDO();
		BeanUtils.copyProperties(userModel, userDO);
		return userDO;
	}

	/**
	 * vo to model
	 * 
	 * @param userVO
	 * @return
	 */
	public static UserModel voToModel(UserVO userVO) {
		// 不能为空
		UserModel userModel = new UserModel();
		userModel.setName(userVO.getName());
		userModel.setSchoolNo(userVO.getSchoolNo());
		userModel.setPwd(userVO.getPwd());
		userModel.setSex(Integer.valueOf(userVO.getSex()));
		userModel.setRole(Integer.valueOf(userVO.getRole()));
		userModel.setEmail(userVO.getEmail());
		userModel.setPhone(userVO.getPhone());
		return userModel;
	}
}
